package org.example.mylogin.controller;

import cn.hutool.crypto.digest.BCrypt;
import jakarta.annotation.Resource;
import org.example.mylogin.common.Result;
import org.example.mylogin.dto.MemberLoginDTO;
import org.example.mylogin.entity.Member;
import org.example.mylogin.service.MemberService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 会员表 前端控制器
 * </p>
 *
 * @author wuyunbin
 * @since 2024-04-12
 */
@RestController
@RequestMapping("/member")
public class MemberController {

    @Resource
    private MemberService memberService;

    @PostMapping("/login")
    public Result login(@RequestBody MemberLoginDTO memberLoginDTO)
    {
        String password = BCrypt.hashpw(memberLoginDTO.getPassword());

        String token = memberService.login(memberLoginDTO);

        return Result.success(token);
    }



}
